#ifndef __TBD__TRIVIALGRAPHFORMAT
#define __TBD__TRIVIALGRAPHFORMAT

#include <string>
#include <vector>
#include <iostream>

/// @defgroup TrivialGraphFormat Trivial Graph Format Generator
/// @ingroup MP4FileLibTest
/// The namespace TrivialGraphFormat includes a data structure called
/// a "sheet" containing nodes and associations. This builds a simple
/// unweighted graph that can be written in the TGF format supported
/// by yEd (http://www.yworks.com).

/// @brief Trivial graph data structure
/// @ingroup TrivialGraphFormat
namespace TrivialGraphFormat
{
  using namespace std;

  /// @ingroup TrivialGraphFormat
  class Association
  {
    int    m_nNodeFrom;
    int    m_nNodeTo;
    string m_strName;
  public:
    Association( int nNodeFrom, int nNodeTo, const string& strName="" )
      : m_nNodeFrom(nNodeFrom)
      , m_nNodeTo(nNodeTo)
      , m_strName(strName)
    {
    }
    void dump( ostream& os ) const
    {
      os << m_nNodeFrom << " " << m_nNodeTo << " " << m_strName << endl;
    }
  };

  /// @ingroup TrivialGraphFormat
  class Sheet
  {
    vector<string>      m_aNodes;
    vector<Association> m_aAssociations;
  public:
    int add( const string& strName )
    {
      m_aNodes.push_back(strName);
      return (int)(m_aNodes.size()-1);
    }
    void add( const Association& association )
    {
      m_aAssociations.push_back(association);
    }
    void dump( ostream& os ) const
    {
      for( unsigned int i=0; i<m_aNodes.size(); i++ )
        os << i << " " << m_aNodes[i] << endl;
      os << "#" << endl;
      for( unsigned int i=0; i<m_aAssociations.size(); i++ )
        m_aAssociations[i].dump(os);
    }
  };
}

#endif
